//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    appBgColor: '#172c3d',
    appColor: '#ffffff',
    textShadow: false,
    shanshuo: false,
    fontSize: 80,
    step: 4,
    show: false,
    inputText: '审核人员你真好看...',
    controls: [
      {
        title: "屏幕背景",
        colors: ["#172c3d", "#264863", "#014d67", "#aedd81", "#ffffff"]
      }, {
        title: "字体颜色",
        colors: ["#ffffff", "#ff0000", "#172c3d", "#264863", "#014d67", "#aedd81"]
      },
      {
        title: "字体特效",
        content: [
          {
            text: "阴影",
            bool: false
          },
          {
            text: "闪烁",
            bool: false
          }
        ]
      },
    ],
    controls2: [
      {
        title: "字体大小",
        array: [40, 50, 60, 70, 80, 90, 100]
      },
      {
        title: "跑动速度",
        array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      },
    ]
  },
  onLoad: function () {

    // wx.setNavigationBarTitle({
    //   title: '',
    // });
    // wx.setNavigationBarColor({
    //   frontColor: 'rgba(0,0,0,0)',
    //   backgroundColor: 'rgba(0,0,0,0)',
    // })
    wx.showNavigationBarLoading();
    setTimeout(function () { wx.hideNavigationBarLoading(); }, 3000);


    let spW = 0;
    //创建节点选择器
    var query = wx.createSelectorQuery();
    query.select('#sp').boundingClientRect()
    query.exec(function (res) {
      //res就是 所有标签为sp的元素的信息 的数组
      console.log(res);
      //取高度
      console.log(res[0].width);
      spW = res[0].width;
    })


    let wH = wx.getSystemInfoSync().windowHeight;
    this.setData({
      contentW: wH + spW,
      danmuL: wH + spW
    })

    setInterval(() => {
      let step = this.data.step;
      let dl = this.data.danmuL - step;
      if (dl < -(wH + spW)) {
        dl = this.data.contentW
      }
      this.setData({
        danmuL: dl
      })

    }, 20);







  },


  bi(e) {
    console.log(e.detail.value)
    this.setData({
      inputText: e.detail.value
    })
  },

  clickShowHide() {
    let s = !this.data.show
    this.setData({
      show: s
    })
  },


  checkAppBgColor(e) {

    let idx = e.currentTarget.dataset.idx
    let idxx = e.currentTarget.dataset.idxx
    let color = e.currentTarget.dataset.color
    console.log(idx)
    console.log(idxx)
    console.log("color:", color)
    if (idx == 0) {
      this.setData({
        appBgColor: color
      })

      // wx.setNavigationBarColor({

      //   frontColor: '#ffffff',

      //   backgroundColor: color
      // })

    }
    else if (idx == 1) {
      this.setData({
        appColor: color
      })
    }
    else if (idx == 2) {

      let contr = this.data.controls
      contr[idx].content[idxx].bool = !contr[idx].content[idxx].bool
      console.log("真假？->", contr[idx].content[idxx].bool)
      if (idxx == 0) {
        this.setData({
          controls: contr,
          textShadow: contr[idx].content[idxx].bool
        })
      } else if (idxx == 1) {
        this.setData({
          controls: contr,
          shanshuo: contr[idx].content[idxx].bool
        })
      }

    }

  },
  // pickerChange2(e) {

  //   let idx1 = e.currentTarget.dataset.idx;
  //   let idx2 = e.detail.value;
  //   console.log("idx1->", idx1)
  //   console.log("idx2->", idx2)
  //   console.log("this.data.controls2[idx1].array[idx2]-->", this.data.controls2[idx1].array[idx2])

  //   let nowStep = this.data.controls2[idx1].array[idx2];
  //   console.log("nowStep->", nowStep)
  //   this.setData({
  //     step: nowStep,
  //     index: e.detail.value
  //   })

  // },

  //字号
  pickerChange1(e) {
    let idx2 = e.detail.value;
    console.log("idx2->", idx2)
    console.log("this.data.controls2[0].array[idx2]-->", this.data.controls2[0].array[idx2])
    this.setData({
      fontSize: this.data.controls2[0].array[idx2],
      index: e.detail.value
    })
  },
//速度
  pickerChange2(e){
    let idx2 = e.detail.value;
    console.log("idx2->", idx2)
    console.log("this.data.controls2[1].array[idx2]-->", this.data.controls2[1].array[idx2])
    this.setData({
      step: this.data.controls2[1].array[idx2],
      index2: e.detail.value
    })
  }
})
